package com.rockcent.mall.lib.repository;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.rockcent.common.common.PageResult;
import com.rockcent.common.common.SQLListDoing;
import com.rockcent.common.common.SQLObjectDoing;
import com.rockcent.common.common.SQLPageDoing;
import com.rockcent.mall.lib.domain.MerchantGiftPacketShare;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by zhangjh on 2016/11/4.
 */
@Repository
public class MerchantGiftPacketShareRepositoryImpl implements MerchantGiftPacketShareRepositoryCustom {

    private static final Logger log = LoggerFactory.getLogger(MerchantGiftPacketShareRepositoryImpl.class);

    @Autowired
    private NamedParameterJdbcTemplate jdbcTemplate;
    @Autowired
    private ObjectMapper objectMapper;

    @Override
    public List<MerchantGiftPacketShare> findGiftIdBySharedCustomerId(Long customerId){
        SQLListDoing doing = (sql, fields, params, typeReferenceMap) -> {
            sql.append("select %s from gift_packet_share gps where gps.shared_customer_id = :customerId ");
            fields.append("gps.*");
            params.put("customerId",customerId);
        };
        return doing.go(MerchantGiftPacketShare.class,objectMapper,jdbcTemplate,log);
    }
}
